package com.casic.ops.task.impl;

import com.casic.ops.configs.ApplicationContextUtil;
import com.casic.ops.service.api.ApplicationPipelineTaskService;
import com.orion.utils.time.Dates;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName ops-platform
 * @Description 流水线任务实现
 * @Author mianbin
 * @Date 2022/5/31 10:59
 * @Version 1.0
 **/
@Slf4j
public class PipelineTaskImpl implements Runnable {

    protected static ApplicationPipelineTaskService applicationPipelineTaskService = ApplicationContextUtil.getBean(ApplicationPipelineTaskService.class);

    private Long pipelineRecordId;

    public PipelineTaskImpl(Long pipelineRecordId) {
        this.pipelineRecordId = pipelineRecordId;
    }

    @Override
    public void run() {
        log.info("定时执行流水线任务-触发 releaseId: {}, time: {}", pipelineRecordId, Dates.current());
        applicationPipelineTaskService.execPipeline(pipelineRecordId, true);
    }

}
